package com.msg.impl;

import javax.swing.JTextArea;

import com.msg.ShowMessage;

/**
 * Title: <br>
 * Description: <br>
 * Copyright: WangGuangya<br>
 * Company: WangGuangya<br>
 * 
 * @author WangGuangya
 * @version 1.0
 * @date 2018-02-23
 */

public class Log2TextArea implements ShowMessage {

	JTextArea text;
	StringBuffer sb = new StringBuffer();

	public Log2TextArea(JTextArea textArea) {
		this.text = textArea;
	}
	
	@Override
	public void print(String str) {
		System.out.println(str);
		text.setText(str);
	}

	@Override
	public void close() {
	}

	@Override
	public void append(String str) {
		System.out.println(str);
		sb.append(str);
		text.setText(sb.toString());
		text.setCaretPosition(text.getText().length());
		text.paintImmediately(text.getBounds());
	}
}
